<!DOCTYPE html>
<html>

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Sugar</title>
</head>

<body>
  <script>
    const cartList = [
      { goods_id: 111, goods_check: true },
      { goods_id: 222, goods_check: false },
      { goods_id: 333, goods_check: false },
      { goods_id: 444, goods_check: false },
    ];

    // 过滤出选中商品，其实种类的数量就是数组的长度 length
    const res = cartList.filter(item => item.goods_check === true);
    console.log(res);

    // 淘宝计算规则：计算选中商品<种类数量>
    const kindCount = cartList.filter(item => item.goods_check).length;
    console.log('选中商品种类个数', kindCount);

  </script>
</body>

</html>